// pages/splash/splash.js

const App = getApp()

Page({
  data: {
    init: false,
    loading: false,
    conf: {},

    sld: false,

    keyl: false,
    key: '',
    pwd: ''
  },
  onLoad() {
    App.doPost({
      uri: '/app/base/data/config',
      body: {},
      fnSucc: resp => {
        console.log("33333333")
        console.log(resp)
        this.setData({
          conf: resp.data
        })
        let sld = wx.getStorageSync('App.Sld') !== 'true'
        if (!sld) {
          this.waitForReady()
        } else {
          this.setData({
            sld: sld
          })
        }
      }
    })

  },
  waitForReady() {
    console.log(App.Global)
    if (App.Global.OpenId) {
      wx.redirectTo({
        url: '/pages/index/index',
      })
    } else {
      setTimeout(() => {
        this.waitForReady()
      }, 200);
    }
  },

  toAgreement() {
    wx.navigateTo({
      url: `/pages/funcs/web?url=${this.data.conf.web.yhxy}`,
    })
  },
  toPolicy() {
    wx.navigateTo({
      url: `/pages/funcs/web?url=${this.data.conf.web.yszc}`,
    })
  },
  doPass() {
    wx.setStorageSync('App.Sld', 'true')
    this.setData({
      sld: false
    })
    this.waitForReady()
  },
})